const RootUrl = "https://netclass.jahanxah.cn/";
const RequestUrl = RootUrl + "api/";
const platform = '';
App({
  onLaunch: function () {
    if (wx.cloud) {
      wx.cloud.init({
        traceUser: true
      })
    }
    wx.getSystemInfo({
      success: e => {
        this.globalData.StatusBar = e.statusBarHeight;
        this.globalData.RootUrl = RootUrl;
        this.globalData.RequestUrl = RequestUrl;
        this.globalData.platform = e.platform;
        let capsule = wx.getMenuButtonBoundingClientRect();
        if (capsule) {
          this.globalData.Custom = capsule;
          this.globalData.CustomBar = capsule.bottom + capsule.top - e.statusBarHeight;
        } else {
          this.globalData.CustomBar = e.statusBarHeight + 50;
        }
      }
    })

    this.userlogin();
  },

  userlogin() {
    wx.getUserProfile({
      desc: '用于完善会员资料',
      success(res) {
        // console.log(res.userInfo);
        wx.login({
          success(res1) {
            // console.log(res1);
            wx.request({
              url: app.globalData.RequestUrl + 'wxuserLogin',
              method: "POST",
              data: {
                "code": res1.code,
                "userInfo": res.userInfo
              },
              success(res) {
                that.setData({
                  userInfo: res.data.userInfo,
                })
              }
            })
          }
        })
      }
    })
  },
  
  globalData: {

  }




})